package lion.soa.dubbo.anno;

import java.lang.annotation.Annotation;

import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnoProcessor;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;
import lion.soa.dubbo.DubboServiceManager;

/**
 * DubboService 注解扫描处理类
 * 
 * @author lion
 * @email hl_0074@sina.com
 * @date 2016年4月18日
 */
@AnnoProcessor(DubboService.class)
public class DubboServiceAnnoProcessor implements IAnnotationProcessor {

	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Class<?> clazz = (Class<?>) ctx.get(AnnotationProcessorManager.ANNO_CONTEXT_CLASS);

		DubboService ds = (DubboService) anno;

		DubboRef ref = new DubboRef();
		ref.setInterfaceClass(ds.value());
		ref.setServiceClass(clazz);
		ref.setVersion(ds.version());

		DubboServiceManager.regService(ref);
	}
}
